package com.shensi.api.admin.client.system;

import com.shensi.api.admin.client.fallback.system.SysUserClientFallBack;
import com.shensi.common.core.constant.CloudConstant;
import com.shensi.common.core.domain.AjaxResult;
import com.shensi.common.core.domain.entity.SysUser;
import com.shensi.common.core.page.TableDataInfo;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.cloud.openfeign.SpringQueryMap;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;

/**
 * @author: budian
 * @since: 2023/11/30
 */
@FeignClient(
        value = CloudConstant.ADMIN_SERVER,
        fallbackFactory = SysUserClientFallBack.class)
@Component
public interface SysUserClient {
    /**
     * 获取用户列表
     */
    @GetMapping("/system/user/list")
    public TableDataInfo list(@SpringQueryMap SysUser user);

    @GetMapping("/system/user/listEnterpriseUser")
    public List<SysUser> listEnterpriseUser(@SpringQueryMap SysUser user);

    @GetMapping("/system/user/listUser")
    public TableDataInfo listUser(@SpringQueryMap SysUser user);


    @GetMapping("/system/user/export")
    public AjaxResult export(@SpringQueryMap SysUser user);


    @PostMapping("/system/user/importData")
    public AjaxResult importData(@RequestParam("file") MultipartFile file,@RequestParam("updateSupport") boolean updateSupport) throws Exception;

    @GetMapping("/system/user/importTemplate")
    public AjaxResult importTemplate();

    /**
     * 根据用户编号获取详细信息
     */
    @GetMapping(value = {"/system/user/{userId}"})
    public AjaxResult getInfo(@PathVariable(value = "userId", required = false) Long userId);


    /**
     * 根据用户信息获取当前的用户
     */
    @GetMapping(value = {"/system/user/getUserInfo/{userId}"})
    public AjaxResult getUserInfo(@PathVariable(value = "userId", required = false) Long userId);

    /**
     * 新增用户
     */
    @PostMapping("/system/user")
    public AjaxResult add(@RequestBody SysUser user);

    @PutMapping(value = "/system/user/editUser")
    public AjaxResult editUser(@RequestBody SysUser user);

    /**
     * 修改用户
     */
    @PutMapping("/system/user")
    public AjaxResult edit(@RequestBody SysUser user);

    /**
     * 删除用户
     */
    @DeleteMapping("/system/user/{userIds}")
    public AjaxResult remove(@PathVariable("userIds") Long[] userIds);


    @PutMapping("/system/user/resetPwd")
    public AjaxResult resetPwd(@RequestBody SysUser user);

    /**
     * 状态修改
     */

    @PutMapping("/system/user/changeStatus")
    public AjaxResult changeStatus(@RequestBody SysUser user);

    /**
     * 代理开启修改
     */
    @PutMapping("/system/user/changeAgentFlag")
    public AjaxResult changeAgentFlag(@RequestBody SysUser user);


    @GetMapping("/system/user/selectUserByUserName")
    SysUser selectUserByUserName(@RequestParam("user") String user);

    @GetMapping("/system/user/selectUsernameByPhoneNumber")
    List<String> selectUsernameByPhoneNumber(@RequestParam("phone") String phone);
}
